package com.clientes;

import java.io.InputStream;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.json.JSONObject;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ContentProviderOperation;
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager.LayoutParams;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;




import android.util.Log;
import android.view.View;
import android.widget.Toast;


public class WishListBean {
	
	private int IdCliente;
	private int IdEvento;
	int TIMEOUT_MILLISEC = 10000; 
	public int getIdCliente() {
		return IdCliente;
	}
	public void setIdCliente(int idCliente) {
		IdCliente = idCliente;
	}
	public int getIdEvento() {
		return IdEvento;
	}
	public void setIdEvento(int idEvento) {
		IdEvento = idEvento;
	}
	public WishListBean(int idCliente, int idEvento) {
		super();
		IdCliente = idCliente;
		IdEvento = idEvento;
	}
	
	
	public WishListBean() {
		// TODO Auto-generated constructor stub
	}
	public boolean RegistrarWishList(){
		
		boolean respuesta=false;
			try {
				Log.i("webservice","1");
				//StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();

		       	  //StrictMode.setThreadPolicy(policy); 
				
				
				HttpParams httpParams = new BasicHttpParams();
				HttpConnectionParams.setConnectionTimeout(httpParams,
						TIMEOUT_MILLISEC);
				HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
				HttpClient client = new DefaultHttpClient(httpParams);
				//
				 
				Log.i("webservice","2");
				String url = "http://200.16.7.112:3000/client_management/clients/agregar_evento_wishlist/";
				//String url = "http://10.41.96.118/phpWebservice/webservice3.php";

				
				JSONObject json = new JSONObject();
				

				Log.i("webservice","idc: "+IdCliente+ "   ideve:"+IdEvento);
				
				HttpPost httppost  = new HttpPost(url);
				   httppost.setHeader("Content-type", "application/json");
				   json.put("cliente_id", IdCliente);
					json.put("evento_id", IdEvento);
					
					StringEntity se = new StringEntity(json.toString()); 
			        se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
			        
			        httppost.setEntity(se); 		
			        HttpResponse response = client.execute(httppost);
			        String temp = EntityUtils.toString(response.getEntity());
			        
			        Log.i("tag", temp);
			        respuesta=true;
				
				// If the response does not enclose an entity, there is no need
			} catch (Throwable t) {
				return respuesta;
			}
		
			
		return respuesta;
	}

}
